package rhc.common.util;

import java.util.Collection;

import org.apache.commons.lang3.StringUtils;

/**检查空工具类
 * @author rhc
 *
 */
public class NullUtil {

	/**检验多个参数不能为空
	 * @param throwException
	 * @param objects
	 * @return
	 */
	public static boolean objectsIsNull(boolean throwException,Object...objects){
		
		if(null == objects || objects.length == 0){
			if(throwException){
				throw new NullPointerException();
			}
			return true;
		}
		
		for(Object object:objects){
			if(null == object || (object instanceof String && StringUtils.isEmpty((String)object)) || (object instanceof Collection && ((Collection)object).isEmpty())){
				if(throwException){
					throw new NullPointerException();
				}
				return true;
			}
		}
		
		return false;
	}
	
}
